package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.entity.SysConsultantFees;
import com.hl.sfzy.mapper.SysConsultantFeesMapper;
import com.hl.sfzy.mapper.SysConsultantFeesMapper;
import com.hl.sfzy.service.SysConsultantFeesService;
import com.hl.sfzy.service.SysConsultantFeesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: sfzy
 * @ClassName SysUserServiceImpl
 * @description:
 * @author: lyp
 * @create: 2024-07-10 14:14
 * @Version 1.0
 **/
@Service("sysConsultantFeesService")
public class SysConsultantFeesServiceImpl implements SysConsultantFeesService {
    @Autowired
    private SysConsultantFeesMapper sysConsultantFeesMapper;

    @Override
    public int add(SysConsultantFees entity) {
        return sysConsultantFeesMapper.insert(entity);
    }

    @Override
    public int edit(SysConsultantFees entity) {
        return sysConsultantFeesMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return sysConsultantFeesMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return sysConsultantFeesMapper.deleteBatch(ids);
    }

    @Override
    public List<SysConsultantFees> find(SysConsultantFees entity) {
        return sysConsultantFeesMapper.select(entity);
    }

    @Override
    public SysConsultantFees findById(Integer id) {
        return sysConsultantFeesMapper.selectById(id);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, SysConsultantFees entity) {
        //开启分页
        PageHelper.startPage(pageNum, pageSize);
        //当前页数据
        List<SysConsultantFees> list = sysConsultantFeesMapper.select(entity);
        //分页信息对象
        PageInfo<SysConsultantFees> pageInfo = new PageInfo<>(list);

        Map<String, Object> map = new HashMap<>();

        //map存储当前页数据、总页数、总记录数
        map.put(CommonConstant.PAGE_LIST, list);
        map.put(CommonConstant.PAGE_TOTAL, pageInfo.getPages());
        map.put(CommonConstant.TOTAL, pageInfo.getTotal());

        return map;
    }
}

